#include<stdio.h>
#include<iostream>
#include<string.h>
#include<cstring>
#include<string>
#include<math.h>
#include<algorithm>
#include<bits/stdc++.h>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
#define cuttime ios::sync_with_stdio(false)
#define swap(x, y) x ^= y, y ^= x, x^= y
#define INF 0x3f3f3f3f
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)
#define scan1(x) scanf("%d",&x)
#define scan2(x,y) scanf("%d%d",&x,&y)
#define scan3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define scanll1(x) scanf("%lld",&x)
#define scanll2(x,y) scanf("%lld%lld",&x,&y)
#define scanll3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define lowbit(x) (x&(-x))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define debug(x) cout <<#x<<": "<<x<<endl
using namespace std;
int main()
{
    int T;
    cin >> T;
    while(T--)
    {
        int n,c;
        int m[101];
        scanf("%d %d",&n,&c);
        int w[50] = {0};
        int flag = 0;
        int a = 0,sum = 0;
        int l = 0,r = 0;
        int x,y;
        int maxsum = 0;
        for(int i = 0; i < n; i++)
        {
            scanf("%d",&m[i]);
            if(m[i] == c)
            {
                if(flag == 1)
                {
                    w[a] = i-1;
                    a++;
                }
                else
                    flag = 1;
            }
            else
                flag = 0;
        }
        for(int i = 0; i < a; i++)
        {
            sum = 2;
            if(w[i]-1 >= 0 && w[i]+2 < n)
            {
                l = w[i] - 1;
                r = w[i] + 2;
            }
            else
            {
                maxsum = max(maxsum,sum);
                continue;
            }
            while(m[l] == m[r])
            {
                x = 1,y = 1;
                if(l-x >= 0)
                {
                    if(m[l-x] != m[l])
                        x = 0;
                }
                else
                    x = 0;
                if(r+y < n)
                {
                    if(m[r+y] != m[r])
                        y = 0;
                }
                else
                    y = 0;
                if(x+y > 0)
                {
                    sum = sum+2+x+y;
                }
                else
                    break;
                if(l-x-1 >= 0 && r+y+1 < n)
                {
                    l = l-x-1;
                    r = r+y+1;
                }
                else
                    break;
            }
            maxsum = max(maxsum,sum);
        }
        cout << maxsum << endl;
    }
}
